import { Goods } from "@/api/service/goods/types";

import { setStep } from "./step";
import { Statistics } from "./types";

type vk = {
  value: any;
  label: string;
  /*
      0：百分比
      1：具体数值
  */
  type: 0 | 1;
};

export const productKeys = ref<string[]>([]);

const formData = {
  visible: false,
  deptId: "",
  status: "0",
  id: "",
  name: "",
  type: "0",
  startTime: "",
  endTime: "",
  work: [] as string[],
  rangeTime: [] as string[],
  rangDate: [] as string[],
  template: undefined,
  date: "",
  fields: [
    { value: 100, label: "retailPrice", type: 0 },
    { value: 100, label: "memberPrice", type: 0 },
    { value: 100, label: "salePrice", type: 0 }
  ] as vk[]
};
export const form = ref(formData);

export const resetForm = () => {
  form.value = JSON.parse(JSON.stringify(formData));
  productKeys.value = [];
  setStep(1);
};
export const planOptions = [
  {
    label: "单次",
    value: "0"
  },
  {
    label: "每天",
    value: "1"
  },
  {
    label: "自定义日期",
    value: "2"
  },
  {
    label: "星期",
    value: "3"
  }
];

export const typeOptions = [
  {
    label: "%",
    value: 0
  },
  {
    label: "值",
    value: 1
  }
];
export const getType = (type: string) => {
  return translateOptions(planOptions, "定时任务").find((e) => {
    if (e.value == type) {
      return e;
    }
  });
};
export const goodsList = ref<Goods[]>([]);

export const statistics = ref<Statistics>({
  count: 0,
  desc: "",
  resolutionId: ""
});
